import { PageTool } from "../../../../common/global/PageTool";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ImagesConst } from "../../../resource/ImagesConst";
import { EffectManager } from "../../../manager/EffectManager";
import { GuildAnimalType } from "../info/GuildAnimalType";
import { ItemCellRenderer } from "../../common/ItemCellRenderer";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { Cache } from "../../../cache/Cache";
import { GuildUtil } from "../info/GuildUtil";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
import { LineBox } from "../../guide/LineBox";
type int = number;
//class GuildAnimalRewardPanel2
    
    export  class GuildAnimalRewardPanel2 /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._pageTool = new PageTool([], 5);
            this.init();
            return;
        }

        public updateItemByIndex(arg1: int): void
        {
            this._lineBox.x = 123 + arg1 % 10 * 130;
            this._lineBox.y = -2;
            this._itemList.dataProvider = new DataProvider(GameDefConfig.instance.getGuildAnimalRewards(arg1).slice(0, 12));
            return;
        }

        /* internal  */init(): void
        {
            var loc1=null;
            this._label = ObjCreate.createGTextField(Language.getString(57619), 0, 10, 220, 20, this, GlobalStyle.textFormat6);
            this._label.autoSize = flash.text.TextFieldAutoSize.LEFT;
            ObjCreate.createBg(0, 35, 585, 45, this, ImagesConst.RemainningTimeBg);
            this._lineBox = EffectManager.getLineBox(64, 32, [16776960]);
            this.addChild(this._lineBox);
            var loc2=0;
            while (loc2 < 3) 
            {
                loc1 = ObjCreate.createGButton(GuildAnimalType.getTypeName(loc2), 125 + loc2 * 130, 0, 60, 28, this);
                loc1.name = loc2.toString();
                loc1.addEventListener(flash.events.MouseEvent.CLICK, this.onRewardBtnClickHandler);
                ++loc2;
            }
            var loc3=0;
            while (loc3 < 12) 
            {
                ObjCreate.createBg(32 + loc3 * 43, 37, 38, 38, this, ImagesConst.PackItemBg);
                ++loc3;
            }
            this._itemList = ObjCreate.createTileList(34, 39, 43 * 5, 38, this);
            this._itemList.setSize(520, 38);
            this._itemList.columnWidth = 43;
            this._itemList.rowHeight = 38;
            this._itemList.setStyle("cellRenderer", ItemCellRenderer);
            return;
        }

        /* internal  */onRewardBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=int((arg1.target as GButton).name);
            var loc2=Cache.instance.guildAnimal.animalInfo;
            if (loc2) 
            {
                this.updateItemByIndex(int(GuildUtil.getTypeByBossId(loc2.bossId) + loc1));
            }
            else 
            {
                this.updateItemByIndex(int("1" + loc1));
            }
            return;
        }

        /* internal */ /* var */_label: GTextFiled;

        /* internal */ /* var */_itemList: GTileList;

        /* internal */ /* var */_lineBox: LineBox;

        /* internal */ /* var */_itemsArray: Array<any>;

        /* internal */ /* var */_pageTool: PageTool;

        /* internal */ /* var */_page: int=1;
    }
